<?php
/***************************************************************************
 *   Copyright (C) 2007 by Andrea Blankenstijn, David Dieulivol            *
 *   darkan9el@gmail.com, daviddieulivol5@hotmail.com                      *
 *                                                                         *
 *   All rights reserved.                                                  *
 *   This work is released under the terms of the New BSD License.         *
 *   See LICENSE.BSD file for licensing details                            *
 ***************************************************************************/
/* * *
 * $Id: addGallery.php 49 2007-08-27 18:23:57Z DarkAn9el $
 * * */

@$action = $_GET['action'];

if($action == 'send')
{
	@$desc   = htmlspecialchars(trim($_POST['desc']));
	@$online = (int) $_POST['isOnline'];
	@$name   = htmlspecialchars(trim($_POST['name']));

	if(empty($desc) OR !is_int($online) OR empty($name))
		die('Champ(s) invalide(s)');

	try
	{
		$admin = new AdminGallery($odb);
		$galId = $admin->addGallery($name, $desc, $online);
	}
	catch(Exception $e)
	{
		die('Exception de AdminGallery : '. $e->getMessage());
	}

	echo '<p>Galerie crée, tentative d\'affichage des données enregistrées</p>';

	try
	{
		$photo = new Gallery($odb, $galId);

		$date  = strftime('%A, %d %B %Y', strtotime($photo->getCreationDate()));
		$desc  = $photo->getDescription();
		$name  = $photo->getName();
	
		echo '<h1>', $name,' (enregistrée le ', $date, ')</h1>';
		echo '<p><em>', $desc,'</em></p>';
	}
	catch(Exception $e)
	{
		die('Erreur de Photo : '. $e->getMessage());
	}
	
}
else
{
?>

<form action="?addGallery&amp;action=send" method="post">
	<p>Ajouter une galerie</p>

	<label>Nom&nbsp;:</label>
	<input type="text" name="name" size="30" maxlength="40" /><br />

	<label>Description&nbsp;:</label><br/>
	<textarea name="desc" rows="10" cols="50" wrap="on">
	</textarea><br/>

	<label>En ligne&nbsp;:&nbsp;</label>
	<input type="checkbox" name="isOnline" value="1" /><br/>

	<input type="submit" />  
</form>

<p><em>$Id: addGallery.php 49 2007-08-27 18:23:57Z DarkAn9el $</em></p>

<?php
}
?>